//
//  MateListCollectionViewCell.m
//  TQY
//
//  Created by 甘世清 on 2024/10/2.
//

#import "MateListCollectionViewCell.h"

@implementation MateListCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.masksToBounds = YES;
        self.clipsToBounds = YES;
        [self SQ_UIViewForSelfView];
    }
    return self;
}
/// 添加ui
-(void)SQ_UIViewForSelfView
{
    self.headerView = [[UIImageView alloc]init];
    self.headerView.layer.cornerRadius = 20;
    self.headerView.layer.masksToBounds = YES;
    self.headerView.layer.borderWidth = 2;
    self.headerView.contentMode  = UIViewContentModeScaleAspectFill;
    self.headerView.clipsToBounds = YES;
    [self.contentView addSubview:self.headerView];
    [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(40);
            make.centerX.centerY.equalTo(self.contentView);
    }];
    [self.contentView addSubview:self.genderImage];
    [self.genderImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(12);
            make.bottom.left.equalTo(self.headerView);
    }];
    [self.contentView addSubview:self.gengduoLabel];
    [self.gengduoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(40);
            make.centerX.centerY.equalTo(self.contentView);
    }];
}
- (void)setDic:(NSMutableDictionary *)dic{
    _dic = dic;
    NSString * header = [NSString stringWithFormat:@"%@",[dic objectForKey:@"portrait"]];
    [self.headerView sd_setImageWithURL:SQURLImage(header) placeholderImage:SQGetImage(@"1")];
    NSString * gender = [NSString stringWithFormat:@"%@",[dic objectForKey:@"gender"]];
        if ([gender isEqualToString:@"2"]) {
            self.headerView.layer.borderColor = SQColor(@"#FF41B1").CGColor;
            self.genderImage.image = SQGetImage(@"女");
        } else {
            self.headerView.layer.borderColor = SQColor(@"#41C4FF").CGColor;
            self.genderImage.image = SQGetImage(@"男");
        }
}
- (UILabel *)gengduoLabel{
    if (!_gengduoLabel) {
        _gengduoLabel = [[UILabel alloc]init];
        _gengduoLabel.text = SQNSLocalString(@"更多");
        _gengduoLabel.backgroundColor = SQColor3DA59D;
        _gengduoLabel.textColor = UIColor.whiteColor;
        _gengduoLabel.font = FONT_REGULAR(12);
        _gengduoLabel.layer.cornerRadius = 20;
        _gengduoLabel.hidden = YES;
        _gengduoLabel.textAlignment = NSTextAlignmentCenter;
        _gengduoLabel.layer.masksToBounds = YES;
    }
    return _gengduoLabel;
}
- (UIImageView *)genderImage{
    if (!_genderImage) {
        _genderImage = [[UIImageView alloc]init];
        _genderImage.image = SQGetImage(@"女");
    }
    return _genderImage;
}
@end
